package org.slusk.thynwor.corestructures;

import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;

import org.slusk.thynwor.util.Coordinates;
import org.slusk.thynwor.util.Direction;

public abstract class Resource extends InteractableEntity {

	protected LinkedList<IWorker> interactingAgent;
	
	static {
	
	}
	
	/**
	 * Default constructor.  For now, this extends Entity.  This a good idea? Refactor entity (clean up) and entities
	 * to extend this class?
	 * 
	 * @param env
	 * @param coords
	 * @param actionsRequired
	 */
	public Resource(Environment env, Coordinates coords) {
		super(env, coords);
		this.interactingAgent = new LinkedList<IWorker>();
	}
	
	public boolean isEngaged() {return interactingAgent.size() > 0;}
	public boolean isAvailable() {return interactingAgent.size() == 0;}

	public LinkedList<IWorker> getInteractingAgents() {return interactingAgent;}

	public void addInteractingAgent(IWorker agent) {
		if (!interactingAgent.contains(agent)) {
			interactingAgent.add(agent);
		}
	}
	
	public void removeInteractingAgent(IWorker agent) {
		interactingAgent.remove(agent);
		if (((Entity)agent).getId() == getLeadTowerId()) setLeadTowerId(-1);
		
	}
	
	public void clearInteractingAgents() {
		for (IWorker agent : interactingAgent) {
			agent.forceDisengage();
		}
		interactingAgent.clear();
	}
	
	public abstract boolean isTowable();
	public abstract int getNumRequiredForTowing();
	public abstract boolean isBeingTowed();
	public abstract void setIsBeingTowed(boolean flag);
	public abstract long getLeadTowerId();
	public abstract void setLeadTowerId(long id);
	
	public static void resetStats() {}

	
}
